
package com.beiru.appupdate;

import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.Callback;
import com.allenliu.versionchecklib.v2.AllenVersionChecker;
import com.allenliu.versionchecklib.v2.builder.DownloadBuilder;
import com.allenliu.versionchecklib.v2.builder.UIData;

public class RNAppupdateModule extends ReactContextBaseJavaModule {

  private final ReactApplicationContext reactContext;

  public RNAppupdateModule(ReactApplicationContext reactContext) {
    super(reactContext);
    this.reactContext = reactContext;
  }

  @Override
  public String getName() {
    return "RNAppupdate";
  }

   @ReactMethod
   public void downloadApk(String apkUrl) {
          DownloadBuilder builder = AllenVersionChecker
                  .getInstance()
                  .downloadOnly(
                          UIData.create()
                                  .setDownloadUrl(apkUrl)
                                  .setTitle("提示")
                                  .setContent("是否确认下载，请确认连接wifi")
                  );
          builder.executeMission(getCurrentActivity());

    }
}
